﻿using CRM.Quartz.Jobs;
using System;
using System.IO;
using Topshelf;

namespace CRM.Quartz
{
    class Program
    {
        static void Main(string[] args)
        {
            CallEndMessageJob job = new CallEndMessageJob();
            job.Execute(null);

            Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);

            HostFactory.Run(x =>
            {
                x.RunAsLocalSystem();

                x.SetDescription(Configuration.ServiceDescription);
                x.SetDisplayName(Configuration.ServiceDisplayName);
                x.SetServiceName(Configuration.ServiceName);

                x.Service(factory =>
                {
                    QuartzServer server = new QuartzServer();
                    server.Initialize().GetAwaiter().GetResult();
                    return server;
                });
            });
        }
    }
}
